package com.qjc.demo.proxy.service;

import com.qjc.demo.proxy.service.impl.SingerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @ClassName: DynamicProxyHandle
 * @Description:
 * @Author: qjc
 * @Date: 2021/8/24 5:12 下午
 */
@Service
public class DynamicProxyHandle implements InvocationHandler {

    @Autowired
    private SingerServiceImpl singerService;

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        String invoke = (String) method.invoke(singerService, args);
        return "动态代理，先跟客户探讨价格，然后" + invoke;
    }

}
